import * as actionTypes from '../action-types';
function reducer(state={number:0},action){
    switch(action.type){
        case actionTypes.ADD1:
            let payload = action.payload||1;
            if(action.error){//如果error为true,说明出错
                payload*=-1;
            }
            console.log('payload',payload,'error',action.error)
            return {number:state.number+payload};
        case actionTypes.MINUS1:
            return {number:state.number-1};   
        default:
            return state;     
    }
}
export default reducer;